function DHTML() {
	this.createElement = function (parent, arrHTML, innerText) {
		var obj = this.createAttr(arrHTML, innerText);
		if (parent) {
			parent.appendChild(obj);
		}
		return obj;
	};

	this.removeElement = function (child){
		if (child) {
			child.parentNode.removeChild(child);
		} else {
			alert("Child element has already been removed or does not exist.");
			return false;
		}
	};

	this.removeElementById = function (childId){
		var child =  document.getElementById(childId);
		if (child) {
			child.parentNode.removeChild(child);
		} else {
			alert("Child element has already been removed or does not exist.");
			return false;
		}
	};
	
	this.createAttr = function (arrHTML, innerText) {
		var obj = "";
		if (arrHTML.length > 0) {
			obj = document.createElement(arrHTML[0]);
			for (var i = 1; i < arrHTML.length; i++) {
				var attr = arrHTML[i].split("=");
				this.setAttr (obj, attr[0].replace(" ", ""), attr[1]);
			}
		} else {
			obj = document.createElement(arrHTML[0]);
		}
		if (innerText != null && innerText != "") {
			obj.innerHTML = innerText;
		}
		return obj;
	};

	this.setAttr = function (obj, attrName, value) {
		attrName = attrName.toLowerCase();
		if (attrName == "id") {
			obj.id = value;
		} else if (attrName == "name") {
			obj.name = value;
		} else if (attrName == "class") {
			obj.className = value;
		} else if (attrName == "style") {
			obj.style = value;
		} else if (attrName == "title") {
			obj.title = value;
		} else if (attrName == "align") {
			obj.align = value;
		} else if (attrName == "width") {
			obj.width = value;
		} else if (attrName == "height") {
			obj.height = value;
		} else if (attrName == "border") {
			obj.border = value;
		} else if (attrName == "cellpadding") {
			obj.cellPadding = value;
		} else if (attrName == "cellspacing") {
			obj.cellSpacing = value;
		} else if (attrName == "value") {
			obj.value = value;
		} else if (attrName == "type") {
			obj.type = value;
		} else if (attrName == "disabled") {
			obj.disabled = value;
		} else if (attrName == "readonly") {
			obj.readOnly = value;
		} else if (attrName == "checked") {
			obj.checked = value;
		} else if (attrName == "selected") {
			obj.selected = value;
		} else if (attrName == "colspan") {
			obj.colSpan = value;
		} else if (attrName == "rowspan") {
			obj.rowSpan = value;
		}else if (attrName == "size") {
			obj.size = value;
		}else if (attrName == "cols") {
			obj.cols = value;
		}else if (attrName == "rows") {
			obj.rows = value;
		}else if (attrName == "src") {
			obj.src = value;
		}else if (attrName == "alt") {
			obj.alt = value;
		}else if (attrName == "colspan") {
			obj.colspan = value;
		}else if (attrName == "rowspan") {
			obj.rowspan = value;
		}else if (attrName == "valign") {
			obj.vAlign = value;
		} else if (attrName == "maxlength") {
			obj.maxLength = value;
		} 
		return obj;
	};

	/**
	 * Remove whitespace from the left end of a string.
	 *
	 * @param str [String]
	 *
	 * @return [String] Returns a string with no leading whitespace 
	 */
	this.trimLeft = function(str) {
		str = str || '';
		return str.replace(/^\s+/g, '');
	};

	/**
	 * Remove whitespace from the right end of a string.
	 *
	 * @param str [String]
	 *
	 * @return [String] Returns a string with no trailing whitespace 
	 */
	this.trimRight = function(str) {
		str = str || '';
		return str.replace(/\s+$/g, '');
	};

	/**
	 * Remove whitespace from both ends of a string.
	 *
	 * @param str [String]
	 *
	 * @return [String] Returns a string with no leading or trailing whitespace 
	 */
	this.trim = function(str) {
	  return this.trimLeft(this.trimRight(str));
	};

}